#include"yuechuan.h"

yuechuan::Logger::ptr g_logger = YUECHUAN_LOG_NAME("root");
void test_fiber() {
    static std::atomic<int> s_count{5};
    YUECHUAN_LOG_INFO(g_logger) << "test_fiber";
    sleep(1);
//    yuechuan::Scheduler::GetThis()->schedule(&test_fiber);
    if(--s_count >= 0) {
    // yuechuan::Scheduler::GetThis()->schedule(&test_fiber);
        yuechuan::Scheduler::GetThis()->schedule(&test_fiber, yuechuan::GetThreadId());
    }
}
int main(int argc, char** argv)
{
    yuechuan::Scheduler sc(3, true, "test");
//    yuechuan::Scheduler sc;
    sc.start();
    sleep(2);
    sc.schedule(&test_fiber);

    sc.stop();
    // YUECHUAN_LOG_INFO(g_logger) << "END";
    return 0;
}